home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Procedure Name:
- // performAlignObjects
- //
- // Description:
- //
- //
- // Input Arguments:
- // $option : Whether to set the options to default values.
- // Return Value:
- // command string iff $option==2
- //
-
- //
- // Initialize optionVars for align:
- //
- proc setOptionVars (
- string $prefix,
- int $forceFactorySettings
- )
- {
- string $varName;
- string $toggles[] = {"atl", "axisX", "axisY", "axisZ"};
- int $defaults[] = {0, 1, 0, 0};
- int $i;
-
- for ($i = size($defaults) ; $i-- ; )
- {
- $varName = ($prefix + $toggles[$i]);
- if ($forceFactorySettings || !`optionVar -exists $varName`)
- optionVar -intValue $varName $defaults[$i];
- }
-
- $varName = ($prefix + "mode");
- if ($forceFactorySettings || !`optionVar -exists $varName`)
- optionVar -stringValue $varName "Mid";
- }
-
- global proc updateAlignMode(string $value)
- {
- string $prefix = "align";
- string $strIcons[] = {"Min", "Mid", "Max", "Dist", "Stack"};
- string $varName = $prefix;
-
- for ($j= size($strIcons) ; $j-- ; )
- {
- if ($strIcons[$j] == $value)
- symbolCheckBox -e -v true ($varName+$strIcons[$j]);
- else
- symbolCheckBox -e -v false ($varName+$strIcons[$j]);
- }
-
- if (($value == "Dist") || ($value == "Stack"))
- optionMenuGrp -e -en 0 ($prefix+"atl");
- else
- optionMenuGrp -e -en 1 ($prefix+"atl");
-
- }
-
- global proc performAlignObjectsSetup (string $parent, int $forceFactSettings)
- {
- string $prefix = "align";
-
- setOptionVars($prefix, $forceFactSettings);
- setParent $parent;
-
- string $varName = ($prefix + "atl");
- int $ival = `optionVar -q $varName`;
- if ($ival)
- optionMenuGrp -e -select 2 $varName;
- else
- optionMenuGrp -e -select 1 $varName;
-
- $varName = $prefix + "mode";
- updateAlignMode(`optionVar -query $varName`);
-
- $varName = $prefix + "axis";
- checkBoxGrp -e -v1 `optionVar -query ($varName+"X")` $varName;
- checkBoxGrp -e -v2 `optionVar -query ($varName+"Y")` $varName;
- checkBoxGrp -e -v3 `optionVar -query ($varName+"Z")` $varName;
- }
-
- global proc performAlignObjectsCallback (string $parent, int $doIt)
- {
- string $prefix = "align";
- string $strIcons[] = {"Min", "Mid", "Max", "Dist", "Stack"};
- int $i;
- int $j;
-
- setParent $parent;
-
- string $varName = $prefix + "atl";
- int $ival = `optionMenuGrp -q -select $varName`;
- if ($ival == 2)
- optionVar -intValue $varName 1;
- else
- optionVar -intValue $varName 0;
-
- for ($j= size($strIcons) ; $j-- ; )
- if (`symbolCheckBox -q -v ($prefix+$strIcons[$j])`)
- {
- optionVar -stringValue ($prefix+"mode") $strIcons[$j];
- break;
- }
- string $varName = $prefix+"axis";
- optionVar -intValue ($varName+"X") `checkBoxGrp -q -v1 $varName`;
- optionVar -intValue ($varName+"Y") `checkBoxGrp -q -v2 $varName`;
- optionVar -intValue ($varName+"Z") `checkBoxGrp -q -v3 $varName`;
-
- if ($doIt)
- {
- performAlignObjects 0;
- addToRecentCommandQueue "performAlignObjects 0" "align";
- }
- }
-
- proc AlignObjectsOptions (string $prefix)
- {
- string $commandName = "performAlignObjects";
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- string $strIcons[] = {"Min", "Mid", "Max", "Dist", "Stack"};
- string $tips[] = {
- "Align objects' bounding boxes to the minimum value",
- "Align objects' bounding boxes to the middle value",
- "Align objects' bounding boxes to the maximum value",
- "Evenly distribute space between objects' bounding boxes",
- "Align objects' bounding boxes adjacently"};
-
- string $layout = getOptionBox();
- setParent $layout;
- setUITemplate -pushTemplate DefaultTemplate;
- waitCursor -state 1;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- rowColumnLayout -nc (1+size($strIcons))
- -cw 1 165 -cw 2 40 -cw 3 40 -cw 4 40 -cw 5 40 -cw 6 40;
-
- text -al "right" -l "Align Mode :";
- for ($j = 0 ; $j < size($strIcons) ; $j++ )
- {
- symbolCheckBox
- -cc ("updateAlignMode "+$strIcons[$j])
- -oni ("alignOn"+$strIcons[$j]+".xpm")
- -ofi ("align"+$strIcons[$j]+".xpm")
- -ann $tips[$j]
- ($prefix+$strIcons[$j]);
- }
-
- text -al "right" -l "";
- for ($j = 0 ; $j < size($strIcons) ; $j++ )
- {
- text -al "center" -l $strIcons[$j];
- }
-
- setParent ..;
- separator -h 5 -style "none";
-
- checkBoxGrp -numberOfCheckBoxes 3
- -label "Align In :" -labelArray3 "World X" "World Y" "World Z"
- ($prefix+"axis");
-
- optionMenuGrp -l "Align to :" ($prefix+"atl");
- menuItem -l "Selection Average";
- menuItem -l "Last Selected Object";
- setParent -m ..;
-
- waitCursor -state 0;
- setUITemplate -popTemplate;
-
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit -label "Align"
- -command ($callback + " " + $parent + " " + 1) $applyBtn;
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
- $saveBtn;
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " " + 1) $resetBtn;
-
- setOptionBoxTitle("Align Objects Options");
-
- setOptionBoxHelpTag( "AlignObjectsoptions" );
-
- eval (($setup + " " + $parent + " " + 0));
-
- showOptionBox();
- }
-
- global proc string performAlignObjects (int $option)
- {
- string $prefix = "align";
- string $cmd="";
- switch ($option)
- {
- case 0:
- setOptionVars($prefix, false);
- $cmd = $prefix;
-
- string $varName = ($prefix + "atl");
- if (`optionVar -q $varName`)
- $cmd = $cmd + " -atl";
-
- $varName = ($prefix + "mode");
- string $val = `optionVar -query $varName`;
-
- $varName = ($prefix + "axisX");
- if (`optionVar -query $varName`)
- $cmd = $cmd + " -x "+ $val;
-
- $varName = ($prefix + "axisY");
- if (`optionVar -query $varName`)
- $cmd = $cmd + " -y "+ $val;
-
- $varName = ($prefix + "axisZ");
- if (`optionVar -query $varName`)
- $cmd = $cmd + " -z "+ $val;
-
- evalEcho($cmd);
- break;
-
- case 1:
- AlignObjectsOptions($prefix);
- break;
- case 2:
- $cmd="performAlignObjects 0";
- break;
- }
- return $cmd;
- }
-